//
//  DestinationAnnotationView.m
//  dangdang
//
//  Created by air on 16/3/2.
//  Copyright © 2016年 luweijie. All rights reserved.
//

#import "DestinationAnnotationView.h"

@interface DestinationAnnotationView()

@property (nonatomic, strong, readwrite) DestinationCalloutView * calloutView;

@end

@implementation DestinationAnnotationView

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    if (self.selected == selected)
    {
        return;
    }
    
    self.userInteractionEnabled = YES;
    
    if (selected)
    {
        if (self.calloutView == nil)
        {
            self.calloutView = [[DestinationCalloutView alloc] initWithFrame:CGRectMake(0, 0, 150, 50)];
            self.calloutView.layer.cornerRadius = self.calloutView.bounds.size.height / 2;
            self.calloutView.backgroundColor = [UIColor colorWithRed:48/255.0 green:153/255.0 blue:247/255.0 alpha:1.0];
            self.calloutView.center = CGPointMake(CGRectGetWidth(self.bounds) / 2.f + self.calloutOffset.x,
                                                  -CGRectGetHeight(self.calloutView.bounds) / 2.f + self.calloutOffset.y - 3);
        }
        
        self.calloutView.image = [UIImage imageNamed:@"hk_head.png"];
        self.calloutView.title = self.annotation.title;
        self.calloutView.phoneImage = [UIImage imageNamed:@"hk_phone.png"];
//        self.calloutView.selector = self.method;
        
        [self addSubview:self.calloutView];
    }
    else
    {
        [self.calloutView removeFromSuperview];
    }
    
    [super setSelected:selected animated:animated];
}

@end
